// 定义响应数据结构
import type {AxiosResponse, InternalAxiosRequestConfig} from "axios";

export class BusinessError extends Error {
  public code: number;
  public response?: AxiosResponse;

  constructor(message: string, code: number, response?: AxiosResponse) {
    super(message);
    this.name = 'BusinessError';
    this.code = code;
    this.response = response;
  }
}

export interface ResponseData<T = any> {
  code: number;
  message: string;
  data: T;
  timestamp: number;
}

// 定义 HTTP 配置

export interface HttpConfig extends InternalAxiosRequestConfig {
  // 是否显示全局加载提示
  showLoading?: boolean;
  // 是否显示错误提示
  showError?: boolean;
  // 是否携带认证信息
  withAuth?: boolean;
  // 重试次数
  retry?: number;
}
